2020-2021 Sunseeker Telemetry and Lighting System
usci_b_spi.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usci_b_spi.h - Driver for the USCI_B_SPI Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_USCI_B_SPI_H__
8 #define __MSP430WARE_USCI_B_SPI_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_USCI_Bx__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
29 //
30 //*****************************************************************************
31 typedef struct USCI_B_SPI_initMasterParam {
36  uint8_t selectClockSource;
38  uint32_t clockSourceFrequency;
40  uint32_t desiredSpiClock;
45  uint8_t msbFirst;
50  uint8_t clockPhase;
54  uint8_t clockPolarity;
55 } USCI_B_SPI_initMasterParam;
56 
57 //*****************************************************************************
58 //
61 //
62 //*****************************************************************************
63 typedef struct USCI_B_SPI_changeMasterClockParam {
65  uint32_t clockSourceFrequency;
67  uint32_t desiredSpiClock;
68 } USCI_B_SPI_changeMasterClockParam;
69 
70 
71 //*****************************************************************************
72 //
73 // The following are values that can be passed to the clockPhase parameter for
74 // functions: USCI_B_SPI_initSlave(), and
75 // USCI_B_SPI_changeClockPhasePolarity(); the param parameter for functions:
76 // USCI_B_SPI_initMaster().
77 //
78 //*****************************************************************************
79 #define USCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00
80 #define USCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH
81 
82 //*****************************************************************************
83 //
84 // The following are values that can be passed to the msbFirst parameter for
85 // functions: USCI_B_SPI_initSlave(); the param parameter for functions:
86 // USCI_B_SPI_initMaster().
87 //
88 //*****************************************************************************
89 #define USCI_B_SPI_MSB_FIRST UCMSB
90 #define USCI_B_SPI_LSB_FIRST 0x00
91 
92 //*****************************************************************************
93 //
94 // The following are values that can be passed to the param parameter for
95 // functions: USCI_B_SPI_initMaster(); the clockPolarity parameter for
96 // functions: USCI_B_SPI_initSlave(), and
97 // USCI_B_SPI_changeClockPhasePolarity().
98 //
99 //*****************************************************************************
100 #define USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL
101 #define USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00
102 
103 //*****************************************************************************
104 //
105 // The following are values that can be passed to the param parameter for
106 // functions: USCI_B_SPI_initMaster().
107 //
108 //*****************************************************************************
109 #define USCI_B_SPI_CLOCKSOURCE_ACLK UCSSEL__ACLK
110 #define USCI_B_SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
111 
112 //*****************************************************************************
113 //
114 // The following are values that can be passed to the mask parameter for
115 // functions: USCI_B_SPI_enableInterrupt(), USCI_B_SPI_disableInterrupt(),
116 // USCI_B_SPI_getInterruptStatus(), and USCI_B_SPI_clearInterrupt() as well as
117 // returned by the USCI_B_SPI_getInterruptStatus() function.
118 //
119 //*****************************************************************************
120 #define USCI_B_SPI_TRANSMIT_INTERRUPT UCTXIE
121 #define USCI_B_SPI_RECEIVE_INTERRUPT UCRXIE
122 
123 //*****************************************************************************
124 //
125 // The following are values that can be passed toThe following are values that
126 // can be returned by the USCI_B_SPI_isBusy() function.
127 //
128 //*****************************************************************************
129 #define USCI_B_SPI_BUSY UCBUSY
130 #define USCI_B_SPI_NOT_BUSY 0x00
131 
132 //*****************************************************************************
133 //
134 // Prototypes for the APIs.
135 //
136 //*****************************************************************************
137 
138 //*****************************************************************************
139 //
153 //
154 //*****************************************************************************
155 extern bool USCI_B_SPI_initMaster(uint16_t baseAddress,
156  USCI_B_SPI_initMasterParam *param);
157 
158 //*****************************************************************************
159 //
169 //
170 //*****************************************************************************
171 extern void USCI_B_SPI_changeMasterClock(uint16_t baseAddress,
172  USCI_B_SPI_changeMasterClockParam *param);
173 
174 //*****************************************************************************
175 //
203 //
204 //*****************************************************************************
205 extern bool USCI_B_SPI_initSlave(uint16_t baseAddress,
206  uint8_t msbFirst,
207  uint8_t clockPhase,
208  uint8_t clockPolarity);
209 
210 //*****************************************************************************
211 //
229 //
230 //*****************************************************************************
231 extern void USCI_B_SPI_changeClockPhasePolarity(uint16_t baseAddress,
232  uint8_t clockPhase,
233  uint8_t clockPolarity);
234 
235 //*****************************************************************************
236 //
246 //
247 //*****************************************************************************
248 extern void USCI_B_SPI_transmitData(uint16_t baseAddress,
249  uint8_t transmitData);
250 
251 //*****************************************************************************
252 //
261 //
262 //*****************************************************************************
263 extern uint8_t USCI_B_SPI_receiveData(uint16_t baseAddress);
264 
265 //*****************************************************************************
266 //
282 //
283 //*****************************************************************************
284 extern void USCI_B_SPI_enableInterrupt(uint16_t baseAddress,
285  uint8_t mask);
286 
287 //*****************************************************************************
288 //
304 //
305 //*****************************************************************************
306 extern void USCI_B_SPI_disableInterrupt(uint16_t baseAddress,
307  uint8_t mask);
308 
309 //*****************************************************************************
310 //
327 //
328 //*****************************************************************************
329 extern uint8_t USCI_B_SPI_getInterruptStatus(uint16_t baseAddress,
330  uint8_t mask);
331 
332 //*****************************************************************************
333 //
345 //
346 //*****************************************************************************
347 extern void USCI_B_SPI_clearInterrupt(uint16_t baseAddress,
348  uint8_t mask);
349 
350 //*****************************************************************************
351 //
361 //
362 //*****************************************************************************
363 extern void USCI_B_SPI_enable(uint16_t baseAddress);
364 
365 //*****************************************************************************
366 //
376 //
377 //*****************************************************************************
378 extern void USCI_B_SPI_disable(uint16_t baseAddress);
379 
380 //*****************************************************************************
381 //
390 //
391 //*****************************************************************************
392 extern uint32_t USCI_B_SPI_getReceiveBufferAddressForDMA(uint16_t baseAddress);
393 
394 //*****************************************************************************
395 //
404 //
405 //*****************************************************************************
406 extern uint32_t USCI_B_SPI_getTransmitBufferAddressForDMA(uint16_t baseAddress);
407 
408 //*****************************************************************************
409 //
423 //
424 //*****************************************************************************
425 extern uint8_t USCI_B_SPI_isBusy(uint16_t baseAddress);
426 
427 //*****************************************************************************
428 //
429 // Mark the end of the C bindings section for C++ compilers.
430 //
431 //*****************************************************************************
432 #ifdef __cplusplus
433 }
434 #endif
435 
436 #endif
437 #endif // __MSP430WARE_USCI_B_SPI_H__
uint8_t transmitData
MPU_initThreeSegmentsParam param